var a = getApp(), e = require("../../utils/util.js");

Page({
    data: {
        list: a.globalData.sxdata,
        hei: a.globalData.sheight,
        infodata: null,
        id: 1,
        name: "鼠",
        modalHidden: !1,
        showModalStatus: !1,
        mengshow: !1,
        bottom: "-100%",
        sharelayer: !1,
        sharebox: !1,
        sharemodal: !1,
        bot: "-100%",
        openSettingBtnHidden: !0,
        hide_qcode: 1
    },
    onLoad: function(t) {
        var o = this, s = this, n = s.options.id;
        if (isNaN(n)) for (var i = n.toLowerCase(), d = 0; d < s.data.list.length; d++) i == s.data.list[d].en && (n = d + 1);
        var r = decodeURIComponent(this.options.scene);
        r && ((i = a._get(r, "id")) && (n = i), s.setData({
            id: n
        })), e.getData(n, s, "sx", function() {
            encodeURIComponent("id=" + n);
        }), a.globalData.userInfo ? this.setData({
            userInfo: a.globalData.userInfo,
            hasUserInfo: !0
        }) : this.data.canIUse ? a.userInfoReadyCallback = function(a) {
            o.setData({
                userInfo: a.userInfo,
                hasUserInfo: !0
            });
        } : wx.getUserInfo({
            success: function(e) {
                a.globalData.userInfo = e.userInfo, o.setData({
                    userInfo: e.userInfo,
                    hasUserInfo: !0
                });
            }
        }), s.data.infodata && drawImg.downImg(img_user, "user_" + s.data.userInfo.nickName);
    },
    test: function() {
        var a = encodeURIComponent("id=4");
        wx.navigateTo({
            url: "/pages/sx_info/sx_info?scene=" + a
        });
    },
    clicksx: function(a) {
        var t = this, o = a.currentTarget.dataset.index;
        if (o === t.data.id) return e.hideModal(t), !1;
        e.getData(o, t, "sx", function() {
            var a = "https://api.xzw.com/static/image/xcx/sx_" + o + ".png";
            drawImg.downImg(a, "sximg_" + o);
            var e = "https://api.xzw.com/cp/wxcode?sid=5&scene=" + encodeURIComponent("id=" + o);
            drawImg.downImg(e, "qcode_" + o);
        }), e.hideModal(t, "showModalStatus", "mengshow", "bottom");
    },
    showModal: function() {
        var a = this;
        e.showModal(a, "modalHidden", "showModalStatus", "mengshow", "bottom");
    },
    hideModal: function() {
        var a = this;
        e.hideModal(a, "showModalStatus", "mengshow", "bottom");
    },
    showShareModal: function() {
        var a = this;
        e.showModal(a, "sharebox", "sharemodal", "sharelayer", "bot");
    },
    hideShareModal: function() {
        var a = this;
        e.hideModal(a, "sharemodal", "sharelayer", "bot");
    },
    getUserInfo: function(e) {
        console.log(e), a.globalData.userInfo = e.detail.userInfo, this.setData({
            userInfo: e.detail.userInfo,
            hasUserInfo: !0
        }), drawImg.downImg(e.detail.userInfo.avatarUrl, "user_" + this.data.userInfo.nickName), 
        drawImg.setData({
            userInfo: e.detail.userInfo
        });
    },
    share: function() {
        var a = this;
        a.hideModal(), drawImg.setData({
            sximg: wx.getStorageSync("sximg_" + a.data.id),
            img_user: wx.getStorageSync("user_" + a.data.userInfo.nickName),
            qcode: wx.getStorageSync("qcode_" + a.data.id),
            userInfo: a.data.userInfo,
            desc: a.data.infodata,
            sxname: a.data.name
        }), a.setData({
            hide_qcode: 0
        }), drawImg.draw(a);
    },
    closeQcode: function() {
        this.setData({
            hide_qcode: 1
        });
    },
    get_token: function() {
        var a = this;
        wx.request({
            url: "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx86ac70758738a28c&secret=27c0db2419f2efd39574ef13f185b47f",
            success: function(e) {
                console.log(e), a.setData({
                    token: e.data.access_token
                }), a.get_ewmimg(e.data.access_token);
            }
        });
    },
    get_ewmimg: function(a) {
        encodeURI(4), wx.request({
            url: "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + a,
            dataType: "json",
            method: "POST",
            data: {
                scene: "4",
                path: "pages/sx_info/sx_info"
            },
            success: function(a) {
                console.log(a);
            }
        });
    },
    handleSetting: function(a) {
        var e = this;
        a.detail.authSetting["scope.writePhotosAlbum"] && (e.setData({
            openSettingBtnHidden: !0
        }), drawImg.save_file(e));
    },
    onShareAppMessage: function(a) {
        return "button" === a.from && console.log(a.target), {
            title: "生肖详情",
            path: "/pages/sx/sx_info?id=" + this.data.id
        };
    }
});